//
//  HBIdentifierCheckCtrl.m
//  HuoBao
//
//  Created by chaiyanan on 15/11/30.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBIdentifierCheckCtrl.h"
#import "HBAddBankCtrl.h"
#import "CheckValid.h"
#import "HBUserIdentityParam.h"
#import "HBUserIdentityParser.h"

#define leftMargan  (IsIphone4?15:(IsIphone5?15:(IsIphone6?15:15)))
#define leftMargan1 (IsIphone4?113:(IsIphone5?113:(IsIphone6?113:113)))

@interface HBIdentifierCheckCtrl ()
<UITextFieldDelegate,
UIAlertViewDelegate>

@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *nameLable;
@property (nonatomic, strong) UITextField *nameTF;
@property (nonatomic, strong) UILabel *identifierLable;
@property (nonatomic, strong) UITextField *identifierTF;
@property (nonatomic, strong) UILabel *countLable;
@property (nonatomic, strong) UIButton *submitBtn;
@property (nonatomic, strong) UILabel *msgLable;

@property (nonatomic, strong) NSArray *desAry;

@end

@implementation HBIdentifierCheckCtrl

#pragma mark -
#pragma mark - system

- (void)viewDidLoad
{
  
    [super viewDidLoad];
}

/*
- (void)buildLayout
{
    [super buildLayout];
    self.title = @"身份认证";
    self.view.backgroundColor = [LCCommon getColor:@"f4f5f6"];
 
    
   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange) name:UITextFieldTextDidChangeNotification object:nil];
    
    self.scrollView = [self createScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) contentSize:CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-64) andSuperView:self.view];
    
    self.bgView = [self createSepratorLineWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) backgroundColor:[LCCommon getColor:@"f4f5f6"] superView:self.scrollView];
    UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToEndEdit)];
    [self.bgView addGestureRecognizer:tapG];
    
    [self createContentViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 15) andTitle:nil andPlaceHolder:nil andSuperView:self.bgView];
    [self createContentViewWithFrame:CGRectMake(0, 15, SCREEN_WIDTH, 44) andTitle:@"持卡人" andPlaceHolder:@"请输入持卡人姓名" andSuperView:self.bgView];
    [self createContentViewWithFrame:CGRectMake(0, 59, SCREEN_WIDTH, 44) andTitle:@"身份证号" andPlaceHolder:@"请输入持卡人身份证号" andSuperView:self.bgView];
    
//    self.countLable = [self createLableWithText:@"可验证次数：3次" font:[UIFont systemFontOfSize:14.0f] color:[LCCommon getColor:@"333333"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan, 103, 200, 40) superView:self.bgView];
    
    self.msgLable = [self createLableWithText:@"" font:[UIFont systemFontOfSize:14.0f] color:[LCCommon getColor:@"fc353b"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan, 103, SCREEN_WIDTH-2*(leftMargan), 40) superView:self.bgView];
    self.msgLable.hidden = NO;
    
    self.submitBtn = [self createButtonWithFrame:CGRectMake(leftMargan, 103+56, SCREEN_WIDTH-2*(leftMargan), 44) normalBackgroundColor:[LCCommon getColor:@"f24545"] disabledBackgroundColor:[LCCommon getColor:@"f24545"] higlightedBackgroundColor:[LCCommon getColor:@"f24545"] normalFontColor:[LCCommon getColor:@"ffffff"] higlightedFontColor:[LCCommon getColor:@"ffffff"] disabledFontColor:[LCCommon getColor:@"ff9797"] title:@"提交" contentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter font:[UIFont systemFontOfSize:18] superView:self.view];
//    [self reloadViewType];
    
    
    self.desAry = @[@"1、为了您的资金安全，身份认证未完成时不可进行充值或投资操作",
                    @"2、身份认证审核通过后不可更改",
                    @"3、身份认证最多可尝试3次，失败3次后将进入锁定状态。",
                    @"4、身份认证进入锁定后请联系客服人员帮您解除锁定状态",
                    @"客服电话：400-890-7777"];
    
    CGFloat yyHeight = self.submitBtn.y+self.submitBtn.height+30;
    for (int i=0;i<self.desAry.count;i++)
    {
        UILabel * aLable = [self createDesLableWithText:self.desAry[i] font:[UIFont systemFontOfSize:14.0f] color:[LCCommon getColor:@"666666"] textAlignment:NSTextAlignmentLeft frame:CGPointMake(21, yyHeight) isList:(i<self.desAry.count-1)?YES:NO superView:self.bgView];
        yyHeight += (aLable.height+20);
    }
    if (yyHeight>SCREEN_HEIGHT-64)
    {
        CGRect frameBB = self.bgView.frame;
        frameBB.size.height = yyHeight;
        self.bgView.frame = frameBB;
        self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, yyHeight);
    }
    
}
 */

- (void)buildLayout
{
    [super buildLayout];
    self.title = @"身份认证";
    
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange) name:UITextFieldTextDidChangeNotification object:nil];
    
    self.scrollView = [self createScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) contentSize:CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-64) andSuperView:self.view];
    
    self.bgView = [self createSepratorLineWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) backgroundColor:[LCCommon getColor:@"28292d"] superView:self.scrollView];
    UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToEndEdit)];
    [self.bgView addGestureRecognizer:tapG];
    
    [self createContentViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 15) andTitle:nil andPlaceHolder:nil andSuperView:self.bgView];
    [self createContentViewWithFrame:CGRectMake(0, 15, SCREEN_WIDTH, 44) andTitle:@"持卡人" andPlaceHolder:@"请输入持卡人姓名" andSuperView:self.bgView];
    [self createContentViewWithFrame:CGRectMake(0, 59, SCREEN_WIDTH, 44) andTitle:@"身份证号" andPlaceHolder:@"请输入持卡人身份证号" andSuperView:self.bgView];
    
    //    self.countLable = [self createLableWithText:@"可验证次数：3次" font:[UIFont systemFontOfSize:14.0f] color:[LCCommon getColor:@"777777"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan, 103, 200, 40) superView:self.bgView];
    
    self.msgLable = [self createLableWithText:@"" font:[UIFont systemFontOfSize:14.0f] color:[LCCommon getColor:@"fff25e"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan, 103, SCREEN_WIDTH-2*(leftMargan), 40) superView:self.bgView];
    self.msgLable.hidden = NO;
    
    self.submitBtn = [self createButtonWithFrame:CGRectMake(leftMargan, 103+56, SCREEN_WIDTH-2*(leftMargan), 44) normalBackgroundColor:[LCCommon getColor:@"f24545"] disabledBackgroundColor:[LCCommon getColor:@"bd3737"] higlightedBackgroundColor:[LCCommon getColor:@"f24545"] normalFontColor:[LCCommon getColor:@"ffffff"] higlightedFontColor:[LCCommon getColor:@"ffffff"] disabledFontColor:[LCCommon getColor:@"fd7a7a"] title:@"提交" contentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter font:[UIFont systemFontOfSize:18] superView:self.view];
    //    [self reloadViewType];
    
    
    self.desAry = @[@"1、为了您的资金安全，身份认证未完成时不可进行充值或投资操作",
                    @"2、身份认证审核通过后不可更改",
                    @"3、身份认证最多可尝试3次，失败3次后将进入锁定状态。",
                    @"4、身份认证进入锁定后请联系客服人员帮您解除锁定状态",
                    @"客服电话：400-890-7777"];
    
    CGFloat yyHeight = self.submitBtn.y+self.submitBtn.height+30;
    for (int i=0;i<self.desAry.count;i++)
    {
        UILabel * aLable = [self createDesLableWithText:self.desAry[i] font:[UIFont systemFontOfSize:14.0f] color:[LCCommon getColor:@"b1b1b1"] textAlignment:NSTextAlignmentLeft frame:CGPointMake(21, yyHeight) isList:(i<self.desAry.count-1)?YES:NO superView:self.bgView];
        yyHeight += (aLable.height+20);
    }
    if (yyHeight>SCREEN_HEIGHT-64)
    {
        CGRect frameBB = self.bgView.frame;
        frameBB.size.height = yyHeight;
        self.bgView.frame = frameBB;
        self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, yyHeight);
    }
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark -
#pragma mark - private

- (void)reloadViewType
{
    if (self.countLable.text.length>0)
    {
        NSRange range = NSMakeRange(self.countLable.text.length-1, 1);
        NSRange range1 = [self.countLable.text rangeOfString:@"："];
        if (range.location != NSNotFound&&range1.length != NSNotFound)
        {
            NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:self.countLable.text];
            [attr addAttribute:NSForegroundColorAttributeName value:[LCCommon getColor:@"fc353b"] range:NSMakeRange(range1.location+1, range.location-range1.location-1)];
            self.countLable.attributedText = attr;
            
        }
    }
    
    
    
}

/*
- (UIView *)createContentViewWithFrame:(CGRect)frame andTitle:(NSString *)title andPlaceHolder:(NSString *)placeHolder andSuperView:(UIView *)superView
{
    UIView *bgview = [[UIView alloc]initWithFrame:frame];
    if (title.length>0&&placeHolder.length>0)
    {
        bgview.backgroundColor = [LCCommon getColor:@"ffffff"];
        
        UILabel *titleLable = [self createLableWithText:title font:[UIFont systemFontOfSize:16.0f] color:[LCCommon getColor:@"333333"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan, 0, 95, 44) superView:bgview];
        UITextField *contentTF = [self createTFWithPlaceHolder:placeHolder placeHolderColor:[LCCommon getColor:@"cbcbcb"] font:[UIFont systemFontOfSize:14] color:[LCCommon getColor:@"333333"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan1, 0, SCREEN_WIDTH-(leftMargan + leftMargan1), 44) superView:bgview];
        
        if ([title isEqualToString:@"持卡人"])
        {
            self.nameLable = titleLable;
            self.nameTF = contentTF;
        }
        else
        {
            self.identifierLable = titleLable;
            self.identifierTF = contentTF;
        }
    }
    else
    {
        bgview.backgroundColor = [UIColor clearColor];
    }
    [self createSepratorLineWithFrame:CGRectMake(0, frame.size.height-1/([UIScreen mainScreen].scale), SCREEN_WIDTH, 1/([UIScreen mainScreen].scale)) backgroundColor:[LCCommon getColor:@"dfdfdf"] superView:bgview];
    [superView addSubview:bgview];
    return bgview;
}
 */

- (UIView *)createContentViewWithFrame:(CGRect)frame andTitle:(NSString *)title andPlaceHolder:(NSString *)placeHolder andSuperView:(UIView *)superView
{
    UIView *bgview = [[UIView alloc]initWithFrame:frame];
    if (title.length>0&&placeHolder.length>0)
    {
        bgview.backgroundColor = [UIColor clearColor];
        
        UILabel *titleLable = [self createLableWithText:title font:[UIFont systemFontOfSize:16.0f] color:[LCCommon getColor:@"b1b1b1"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan, 0, 95, 44) superView:bgview];
        UITextField *contentTF = [self createTFWithPlaceHolder:placeHolder placeHolderColor:[LCCommon getColor:@"5f606b"] font:[UIFont systemFontOfSize:14] color:[LCCommon getColor:@"ffffff"] textAlignment:NSTextAlignmentLeft frame:CGRectMake(leftMargan1, 0, SCREEN_WIDTH-(leftMargan + leftMargan1), 44) superView:bgview];
        
        if ([title isEqualToString:@"持卡人"])
        {
            self.nameLable = titleLable;
            self.nameTF = contentTF;
        }
        else
        {
            self.identifierLable = titleLable;
            self.identifierTF = contentTF;
        }
        [self createSepratorLineWithFrame:CGRectMake(leftMargan, frame.size.height-1/([UIScreen mainScreen].scale), SCREEN_WIDTH-2*leftMargan, 1/([UIScreen mainScreen].scale)) backgroundColor:[LCCommon getColor:@"585858"] superView:bgview];
    }
    else
    {
        bgview.backgroundColor = [UIColor clearColor];
    }
    
    [superView addSubview:bgview];
    return bgview;
}

- (UIScrollView *)createScrollViewWithFrame:(CGRect)frame contentSize:(CGSize)contentSize andSuperView:(UIView *)superView
{
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:frame];
    scrollView.contentSize = contentSize;
    scrollView.bounces = NO;
    [superView addSubview:scrollView];
    return scrollView;
}

- (UITextField *)createTFWithPlaceHolder:(NSString *)placeHolder placeHolderColor:(UIColor *)placeColor font:(UIFont *)font color:(UIColor *)fontColor textAlignment:(NSTextAlignment)textAlignment frame:(CGRect)frame superView:(UIView *)superView
{
    UITextField *textField = [[UITextField alloc]initWithFrame:frame];
    textField.backgroundColor = [UIColor clearColor];
    textField.placeholder = placeHolder;
    textField.font = font;
    textField.textColor = fontColor;
    textField.textAlignment = textAlignment;
    textField.delegate = self;
    [textField setValue:placeColor forKeyPath:@"_placeholderLabel.textColor"];
    [superView addSubview:textField];
    return textField;
}

- (UILabel *)createLableWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)fontColor textAlignment:(NSTextAlignment)textAlignment frame:(CGRect)frame superView:(UIView *)superView
{
    UILabel *lable = [[UILabel alloc]initWithFrame:frame];
    lable.backgroundColor = [UIColor clearColor];
    lable.text = text;
    lable.font = font;
    lable.textColor = fontColor;
    lable.textAlignment = textAlignment;
    [superView addSubview:lable];
    return lable;
}

- (UIView *)createSepratorLineWithFrame:(CGRect)frame backgroundColor:(UIColor *)bgColor superView:(UIView *)superView
{
    UIView *sepratorLine = [[UIView alloc]initWithFrame:frame];
    sepratorLine.backgroundColor = bgColor;
    [superView addSubview:sepratorLine];
    return sepratorLine;
}

- (UIButton *)createButtonWithFrame:(CGRect)frame normalBackgroundColor:(UIColor *)normalBGColor disabledBackgroundColor:(UIColor *)disabledBGColor higlightedBackgroundColor:(UIColor *)higlightedBGColor  normalFontColor:(UIColor *)normalFontColor higlightedFontColor:(UIColor *)higlightedFontColor disabledFontColor:(UIColor *)disabledFontColor title:(NSString *)title contentHorizontalAlignment:(UIControlContentHorizontalAlignment)textAlignment font:(UIFont *)font superView:(UIView *)superView
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = frame;
    [button setBackgroundColor:normalBGColor];
    [button setBackgroundColor:normalBGColor forState:UIControlStateNormal];
    [button setBackgroundColor:disabledBGColor forState:UIControlStateDisabled];
    [button setBackgroundColor:higlightedBGColor forState:UIControlStateHighlighted];
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:normalFontColor forState:UIControlStateNormal];
    [button setTitleColor:disabledFontColor forState:UIControlStateDisabled];
    [button setTitleColor:higlightedFontColor forState:UIControlStateHighlighted];
    button.titleLabel.font = font;
    [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
    [button setContentHorizontalAlignment:textAlignment];
    [superView addSubview:button];
    button.enabled = NO;
    [button.layer setCornerRadius:4.0f];
    button.layer.masksToBounds = YES;
    return button;
}


- (UILabel *)createDesLableWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)fontColor textAlignment:(NSTextAlignment)textAlignment frame:(CGPoint)orginPoint isList:(BOOL)isList superView:(UIView *)superView
{
    UILabel *lable;
    if (isList)
    {
        UILabel *listTitleLable = [[UILabel alloc]initWithFrame:CGRectMake(orginPoint.x, orginPoint.y, 50, 10)];
        listTitleLable.backgroundColor = [UIColor clearColor];
        NSRange seRange = [text rangeOfString:@"、"];
        NSString *subText = [text substringToIndex:seRange.location+1];
        listTitleLable.text = subText;
        listTitleLable.font = font;
        listTitleLable.textColor = fontColor;
        listTitleLable.textAlignment = textAlignment;
        [superView addSubview:listTitleLable];
        [listTitleLable sizeToFit];
        CGRect frameAA = listTitleLable.frame;
        frameAA.origin = orginPoint;
        listTitleLable.frame = frameAA;
        
        lable = [[UILabel alloc]initWithFrame:CGRectMake(listTitleLable.origin.x+listTitleLable.frame.size.width, orginPoint.y, SCREEN_WIDTH-listTitleLable.frame.size.width-2*orginPoint.x, 10)];
        lable.backgroundColor = [UIColor clearColor];
        NSString *subTitleText = [text substringFromIndex:2];
        lable.text = subTitleText;
        lable.font = font;
        lable.textColor = fontColor;
        lable.textAlignment = textAlignment;
        lable.numberOfLines = 0;
        [superView addSubview:lable];
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:subTitleText];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
        [paragraphStyle setLineSpacing:7];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, subTitleText.length)];
        lable.attributedText = attributedString;
        
        [lable sizeToFit];
        
        frameAA = lable.frame;
        frameAA.origin = CGPointMake(listTitleLable.origin.x+listTitleLable.frame.size.width, orginPoint.y);
        lable.frame = frameAA;
    }
    else
    {
        lable = [[UILabel alloc]initWithFrame:CGRectMake(orginPoint.x, orginPoint.y, SCREEN_WIDTH-2*orginPoint.x, 10)];
        lable.backgroundColor = [UIColor clearColor];
        lable.text = text;
        lable.font = font;
        lable.textColor = fontColor;
        lable.textAlignment = textAlignment;
        lable.numberOfLines = 0;
        [superView addSubview:lable];
        
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:text];
        [attributedString addAttribute:NSForegroundColorAttributeName value:[LCCommon getColor:@"2281f7"] range:NSMakeRange(5,text.length-5)];
        lable.attributedText = attributedString;
        
        [lable sizeToFit];
        
        CGRect frameAA = lable.frame;
        frameAA.origin = orginPoint;
        lable.frame = frameAA;
        
        UITapGestureRecognizer *tapAA = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToMakePhone:)];
        lable.userInteractionEnabled = YES;
        [lable addGestureRecognizer:tapAA];
        
    }
    
    return lable;
}



#pragma mark -
#pragma mark - active

- (void)clickToMakePhone:(UITapGestureRecognizer *)recognizer
{
    [[[UIAlertView alloc]initWithTitle:@"提示" message:@"确定要拨打电话吗" delegate:self cancelButtonTitle:@"拨打" otherButtonTitles:@"取消", nil]show];
    
}

- (void)clickToEndEdit
{
    [self.nameTF resignFirstResponder];
    [self.identifierTF resignFirstResponder];
}

- (void)clickButton:(UIButton *)sender
{
    NSString *userNameRegex = @"^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]){2,5}$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", userNameRegex];
    BOOL isMatch = [pred evaluateWithObject:self.nameTF.text];
    if (isMatch == NO) {
        self.msgLable.hidden = NO;
        self.msgLable.text = @"请输入正确的持卡人姓名";
        [self.nameTF becomeFirstResponder];
        return;
    }
    
    if (![CheckValid isValidateIdentityCard:self.identifierTF.text])
    {
        self.msgLable.hidden = NO;
        self.msgLable.text = @"请输入正确的持卡人身份证号码";
        [self.identifierTF becomeFirstResponder];
        return;
    }
    
    [self clickToEndEdit];
    if (sender == self.submitBtn)
    {
        [self requestToCheckIdentifier];
    }
}


#pragma mark -
#pragma mark - textField delegate


- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    return YES;
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    //    [self showTFClearBtnWithTextField:textField];
    return YES;
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    return YES;
}

#pragma mark - alertView delegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex==0)
    {
        NSString *text = [self.desAry lastObject];
        NSString *phoneText = [[text substringFromIndex:5] stringByReplacingOccurrencesOfString:@"-" withString:@""];
        NSString* telPhNumber = @"tel://";
        telPhNumber = [telPhNumber stringByAppendingString:phoneText];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telPhNumber]];
    }
}

#pragma mark -
#pragma mark - notify

-(void)textDidChange{
    
    self.msgLable.text = @"";
    
    if (self.nameTF.text.length > 0 && self.identifierTF.text.length > 0)
    {
        self.submitBtn.enabled = YES;
    }
    else
    {
        self.submitBtn.enabled = NO;
    }
}


#pragma mark -
#pragma mark - request


- (void)requestToCheckIdentifier
{
    
    self.msgLable.text = @"";
    [CustomLoadingView showHudToView:self.view];
    HBUserIdentityParam *param = [[HBUserIdentityParam alloc]init];
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    param.username = self.nameTF.text;
    param.cardno = self.identifierTF.text;

    HBUserIdentityParser *parser = [[HBUserIdentityParser alloc]init];
    [NetCenter postDataFromURL:Method_userIdentity params:param parser:parser result:^(ParserResult *myResult) {
        if (myResult.code==0)
        {
            HBAddBankCtrl *addBankCtrl = [[HBAddBankCtrl alloc]initWithNibName:NSStringFromClass([HBAddBankCtrl class]) bundle:nil];
            [self.navigationController pushViewController:addBankCtrl animated:YES];
        }
        else
        {
            self.msgLable.hidden = NO;
            self.msgLable.text = myResult.message;
        }
        [CustomLoadingView hideHudForView:self.view];
    } failure:^(NSError *error) {
        [CustomLoadingView hideHudForView:self.view];
        self.msgLable.text = [error description];
    }];
    
}


@end
